package com.zbowen.seata.consumer.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.zbowen.seata.consumer.client.AccountProviderClient;
import com.zbowen.seata.consumer.entity.TaxTypeCode;
import com.zbowen.seata.consumer.repository.TestDao;
import com.zbowen.seata.consumer.service.TaxTypeCodeService;
import com.zbowen.seata.provider.api.dto.AccountDto;
import org.apache.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class TaxTypeCodeServiceImpl implements TaxTypeCodeService {

    @Autowired
    private TestDao testDao;

    @Autowired
    private AccountProviderClient accountProviderClient;

    @GlobalTransactional(rollbackFor = Exception.class)
    public List<String> test(TaxTypeCode taxTypeCode) {
        LambdaUpdateWrapper<TaxTypeCode> updateWrapper = Wrappers.lambdaUpdate(TaxTypeCode.class);
        updateWrapper.set(TaxTypeCode::getCode, "2000000000000000000");
        updateWrapper.set(TaxTypeCode::getName, "劳务");
        updateWrapper.eq(TaxTypeCode::getId, 1);
        testDao.update(updateWrapper);

        accountProviderClient.updateAccountBala(new AccountDto());

        return Arrays.asList("张三", "李四");
    }
}
